<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // async function div(a, b) {
      //   if (b == 0) {
      //     throw new Error("被除数不能为0");
      //   }
      //   return a / b;
      // }
      function div(a, b) {
        return new Promise((reslove, reject) => {
          if (b == 0) {
            reject(new Error("被除数不能为0"));
          }
          reslove(a / b);
        });
      }
      div(10, 0)
        .then((data) => {
          console.log(data);
        })
        .catch((error) => {
          console.log(error);
        });

      // console.log(div(10, 5));
      // console.log(div(10, 0));
    </script>
  </body>
</html>
